package com.nowcoder.code.lcof;

public class JZ16 {

    public static void main(String[] args) {
        System.out.println(new JZ16().Power(2, 3));
    }

    public double Power(double base, int exponent) {
        if (exponent == 0) {
            return 1;
        }
        boolean b = exponent < 0;
        if (b) {
            exponent = -exponent;
        }

        double j = base;
        for (int i = 1; i < exponent; i++) {
            j = base * j;
        }
        if (b) {
            j = 1 / j;
        }
        return j;
    }

}
